package seed_commerce

import (
	"fmt"
	"gitee.com/theegg/go-brick/app/model/commerce/goods_category"
	"github.com/xormplus/xorm"
	"time"
)

func InitGoodsCategorySeed(db *xorm.Engine) {
	items := make(map[int]goods_category.GoodsCategory)
	items[1] = goods_category.GoodsCategory{
		CatTitle: "玩具",
		ParentId: 0,
		Avatar:   "",
		Status:   1,
		AddTime:  time.Now().Unix(),
		AddIp:    "",
	}

	items[2] = goods_category.GoodsCategory{
		CatTitle: "乐器",
		ParentId: 0,
		Avatar:   "",
		Status:   1,
		AddTime:  time.Now().Unix(),
		AddIp:    "",
	}

	items[3] = goods_category.GoodsCategory{
		CatTitle: "奶粉",
		ParentId: 0,
		Avatar:   "",
		Status:   1,
		AddTime:  time.Now().Unix(),
		AddIp:    "",
	}

	items[4] = goods_category.GoodsCategory{
		CatTitle: "儿童玩具",
		ParentId: 1,
		Avatar:   "",
		Status:   1,
		AddTime:  time.Now().Unix(),
		AddIp:    "",
	}

	count := 0
	errCount := 0
	for _, item := range items {
		_, err := db.Insert(item)
		if err != nil {
			fmt.Println(err.Error())
			errCount++
		} else {
			count++
		}
	}

	fmt.Printf("%5s|%25s|%10d|%8d|\n", "", "goods_category", count, errCount)
}
